// Include this file into reader_read_items.php, head section
/*
function showNewItems(username, key, cid)
{
	var param = "username=" + username;
	param += "&keyword=" + key;
	param += "&channel_id=" + cid;

	$.get("reader_operation.php?action=show_update_item&" + param, 
		function(json) {
			var arrJson = eval('(' + json + ')');
			len = arrJson.length;

			i = 0;
			
			dTitle = $('.new-items > .item-head > .item-title');
			dTime = $('.new-items > .item-head > .item-time');
			dAuthor = $('.new-items > .item-head > .item-author');
			dContent = $('.new-items > .item-content');
			
			interval = window.setInterval(
				function()
				{					
					dTitle.text(arrJson[i].title + ' (' + (i + 1) + '/' + len + ')');
					dTime.text(arrJson[i].pubdate);
					dAuthor.text('by ' + arrJson[i].author);
					dContent.html(arrJson[i].description);
					
					if(++i >= len)
					{
						i = 0;
					}
					
				}
			, 2000);
			
			$('.new-items').mouseover(
				function()
				{
					var item_content = $(this).children('.item-content');
					if(item_content.css('display') == 'none')
					{
						$(this).children('.item-content').show(500);
						//window.clearInterval(interval);
					}
				}
			);
			
			$('.new-items').click(
				function()
				{
					$(this).children('.item-content').toggle(500);
				}
			);
		}
	);
}
*/

function wrapTitle(title, div_name)
{	
	var cTitle = title;
	var cTHeight = parseInt($('#cTitle').css('font-size'));
	var dot = '...';
	
	if(div_name == null || div_name == '')
	{
		div_name = '#cTitle';
	}
	
	$(div_name).text(cTitle);
	
	if($(div_name).height() > cTHeight * 2)
	{
		$(div_name).text('');
		
		var i;
		
		for(i = 0; i < cTitle.length && $(div_name).height() < cTHeight * 2; i++)
		{
			$(div_name).text(cTitle.substring(0,i) + dot);
		}
		
		var wrongTitle = $(div_name).text();
		$(div_name).text(wrongTitle.substring(0, wrongTitle.length - dot.length - 1) + dot);
	}
}

function redirect(cid, http_host, php_self)
{
	window.location.href = 'http://' + http_host + php_self + '?' + cid;
}